<!DOCTYPE html>
<html>

<head>
  <meta charset="utf-8">
  <title>Layui</title>
  <meta name="renderer" content="webkit">
  <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
  <link rel="stylesheet" href="../../layuiAdmin/layui/css/layui.css" media="all">
  <link rel="stylesheet" href="../../src/all.css" media="all">
  <!-- 注意：如果你直接复制所有代码到本地，上述css路径需要改成你本地的 -->
  <style>
    .margin-top {
      margin-top: 20px;
    }

    .h1 {
      font-size: 20px;
      /* padding-left: 50px; */
    }

    .layui-form-label {
      white-space: nowrap;
      width: auto !important;
    }

    .height {
      height: 20px;
    }
  </style>
</head>


<body style="background-color: #fff;">

  <div class="layui-fluid">
    <table class="layui-hide" id="test" lay-filter="test"></table>
  </div>

  <script type="text/html" id="toolbarDemo">
  <div class="layui-btn-container">
    <button class="layui-btn layui-btn-sm layui-top-add" lay-event="add">新建</button>
    <button class="layui-btn layui-btn-sm layui-top-warm" lay-event="exit">编辑</button>
    <button class="layui-btn layui-btn-sm layui-top-danger" lay-event="del">删除</button>
    <button class="layui-btn layui-btn-sm layui-top-success" lay-event="add">导入</button>

  </div>
</script>

  <script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-xs" lay-event="edit">显示</a>
    <!-- <a class="layui-btn layui-btn-xs" lay-event="edit">编辑</a> -->
    <a class="layui-btn layui-btn-danger layui-btn-xs" lay-event="del">删除</a>
  </script>
  <!-- 新建 -->
  <script type="text/html" id="add">
    <form class="layui-form" action=""  class="layui-form model-form" style="padding: 10px;">
      <input name="dictDataId" type="hidden"/>
      <div class="layui-form-item">
        <label class="layui-form-label layui-form-required" style="padding-left: 0;width: 95px;">责任条款:</label>
        <div class="layui-input-block">
          <textarea name="dictDataName" placeholder="请输入字典项名称" class="layui-input"
            lay-verType="tips" lay-verify="required" required></textarea>
        </div>
      </div>
    </form>
  </script>

  <script src="../../layuiAdmin/layui/layui.all.js" charset="utf-8"></script>
  <!-- 注意：如果你直接复制所有代码到本地，上述 JS 路径需要改成你本地的 -->

  <script>
    layui.use(['form', 'layedit', 'laydate', 'table'], function () {
      var table = layui.table
        , form = layui.form
        , layer = layui.layer
        , $ = layui.jquery
      table.render({
        elem: '#test'
        , url: '/js/table.json'
        , toolbar: '#toolbarDemo'
        , title: '用户数据表'
        , cols: [
          [ //标题栏
            { type: 'checkbox', fixed: 'left', }
            , { field: 'dwfk', title: '追究责任条款', align: 'left' }
          ]
        ]

        , page: true
      });
      //头工具栏事件
      table.on('toolbar(test)', function (obj) {
        var checkStatus = table.checkStatus(obj.config.id);
        switch (obj.event) {
          case 'add':
            //新建
            opener('新建')
            break;
          case 'exit':
            opener('编辑')
            break;
          case 'del':
            layer.msg('请选中数据');
            break;
        };
      });
      function opener(mData) {
        //新建
        parent.layer.open({
          type: 1,
          title: mData,
          shadeClose: true,
          // shade: true,
          maxmin: false, //开启最大化最小化按钮
          area: ['60%', '60%'],
          btn: ['确定'],
          content: $('#add').html(),
          success: function (layero) {
          },
          end: function () {
            window.location.reload();
          }

        });
      }
    });
  </script>

</body>

</html>